<!DOCTYPE html>
<html>

	<head>
		<script src="../js/angular.min.js"></script>
		<meta charset="UTF-8">
		<title>倒计时验证码</title>
	</head>

	<body ng-app="appAngular" ng-controller="appController">
		<button ng-bind="btnMsg" ng-click="appClick()"></button>

	</body>

	<script>
		// 初始化angular
		var aa = angular.module("appAngular", []);
		aa.controller("appController", function($scope) {
			var m = 6;
			$scope.btnMsg = "发送验证码";

			$scope.appClick = function(){

				if(m == 6) {
					var si = setInterval(function() {
						
						m = m - 1;
						$scope.btnMsg = m + "秒后可重发"
						$scope.$digest();
						
						if(m==0){
							clearInterval(si);
							flag = true;
							m = 6;
							$scope.btnMsg = "重发验证码";
							$scope.$digest();
						}
						
					}, 1000);

				} 
			};
		});
	</script>

</html>